/*
 * @Descripttion: 成绩管理
 * @version: 
 * @Author: hzx
 * @Date: 2021-03-24 19:44:08
 * @LastEditors: hzx
 * @LastEditTime: 2021-05-13 00:06:46
 */ 

import { get, post } from "@/utils/request";

/**
 * @name: 查询所有学生成绩信息
 * @msg: 
 * @param {*}
 * @return {*}t_id
 */

export async function getCourseList(t_id, sc_id) {
    //console.log(t_id, sc_id)
    let [response, error] = await get(`/course/getCourseList`, { t_id, sc_id });
    //console.log(response)
    let { title, id, type } = response
    return response !== null ? response : error
}

/**
 * @name: 查询班级信息
 * @msg: 
 * @param {*}
 * @return {*}
 */
export async function getClassName(t_id) {
    let [response, error] = await get(`/course/getClassName?t_id=${t_id}`);
    //console.log(response)
    return response !== null ? response : error
}

/**
 * @name: 查询课程信息
 * @msg: 
 * @param {*}
 * @return {*}
 */
export async function getCourseName(t_id) {
    let [response, error] = await get(`/course/getCourseName?t_id=${t_id}`);
    //console.log(response)
    return response !== null ? response : error
}

/**
 * @name: 根据班级名称，课程名查询课程信息
 * @msg: 
 * @param {*}
 * @return {*}
 */
export async function selectCouCla(condition) {
    let { courseName, className } = condition
    let [response, error] = await get(`/course/selectCouCla?`, { courseName, className });
    //console.log(response)
    return response !== null ? response : error
}

/**
 * @name: 根据grade_id修改学生成绩
 * @msg: 
 * @param {*} grade, grade_id 必填
 * @return {*}
 */
export async function updateCourse(data) {
    let { grade, sc_id } = data;
    let [response, error] = await post(`/course/updateCourse`, { grade, sc_id });
    return response !== null ? response : error
}


/**
 * @name:  根据学生id查询未选课程列表
 * @msg:    '未选课程查询成功'
 * @param {*} stu_id
 * @return {*}
 */
export async function checkCourse(stu_id) {
    let [response, error] = await get(`/course/checkCourse?stu_id=${stu_id}`)
    return response !== null ? response : error
}

/**
 * @name: 选课
 * @msg: '课程选择成功'
 * @param {*} data
 * @return {*}
 */
export async function insertCourse(data) {
    let [response, error] = await post(`/course/insertCourse`, data);
    return response !== null ? response : error
}

/**
 * @name: 查询学生已选课程
 * @msg: '学生已选课程查询成功'
 * @param {*}stu_id
 * @return {*}
 */
export async function selStuView(stu_id) {
    let [response, error] = await get(`/course/selStuView?stu_id=${stu_id}`);
    return response !== null ? response : error
}